
if exists(select name from sysobjects where name = 'sp_MenuCheckQuyenVaoTrang')
	drop proc sp_MenuCheckQuyenVaoTrang
go
/*
	Created by: Phuoc NH
	Created on: 13/05/2013 (dd/mm/yyyy)
	Description: 
	--

	File:$sql-scripts/Proc.sp_MenuCheckQuyenVaoTrang.sql
*/

create proc sp_MenuCheckQuyenVaoTrang
@Userid int,
@Menuid int
as
begin
	declare @NhomUserID int
	set @NhomUserID=(select NhomUserid from Users where Userid=@Userid)
	if(@NhomUserID=1)
		begin
			select 1
		end
	else
		begin
			SELeCT a.*, c.*, d.* from tbl_menus a inner join tbl_nhomuser_menu b on a.menuid=b.menuid inner join NhomUser c on b.nhomuserid=c.NhomUserId inner join Users d on d.NhomUserId=c.NhomUserId where d.Userid=@Userid and a.menuid=@Menuid
		end
	
end

